package com.yangmin.rabbit.listener;

import com.yangmin.rabbit.config.RabbitConfig;
import com.yangmin.rabbit.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

/**
 * @author diandian
 * @date 2021-12-12 8:56
 */

/**
 * 监听器  准备去拿对应queue中的内容
 */

@Slf4j
@Component
public class SimpleListener {

    @RabbitListener(queues = RabbitConfig.SIMPLE_QUEUE)
    public void simpleString(String content) {

        log.info("收到的内容是： {}", content);
    }

    @RabbitListener(queues = RabbitConfig.SIMPLE_QUEUE)
    public void simpleObject(User user) {

        log.info("收到的内容是： {}", user);
    }

    /***********主题模式*****************/
    @RabbitListener(queues = RabbitConfig.TOPIC_QUEUE1)
    public void topicMsgEmail(String message) {
        log.info("topic-listener1:" + message);
    }

    @RabbitListener(queues = RabbitConfig.TOPIC_QUEUE2)
    public void topicMsgSm(String message) {
        log.info("topic-listener2:" + message);
    }
}
